package com.xinggq.user.api.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * 密码验证响应DTO
 *
 * @author xinggq
 * @since 2025-10-20
 */
@Data
@Schema(description = "密码验证响应")
public class VerifyPasswordResponse {

  @Schema(description = "验证结果：true-验证通过，false-验证失败")
  private Boolean verified;

  @Schema(description = "用户ID，验证通过时返回")
  private Long userId;

  @Schema(description = "失败原因，验证失败时返回")
  private String failReason;

  @Schema(description = "用户信息，验证通过时返回")
  private UserInfoDTO userInfo;

  /**
   * 创建验证成功的响应
   *
   * @param userId 用户ID
   * @return 验证响应
   */
  public static VerifyPasswordResponse success(Long userId) {
    VerifyPasswordResponse response = new VerifyPasswordResponse();
    response.setVerified(true);
    response.setUserId(userId);
    return response;
  }

  /**
   * 创建验证成功的响应（包含用户信息）
   *
   * @param userId 用户ID
   * @param userInfo 用户信息
   * @return 验证响应
   */
  public static VerifyPasswordResponse success(Long userId, UserInfoDTO userInfo) {
    VerifyPasswordResponse response = success(userId);
    response.setUserInfo(userInfo);
    return response;
  }

  /**
   * 创建验证失败的响应
   *
   * @param reason 失败原因
   * @return 验证响应
   */
  public static VerifyPasswordResponse fail(String reason) {
    VerifyPasswordResponse response = new VerifyPasswordResponse();
    response.setVerified(false);
    response.setFailReason(reason);
    return response;
  }

  public boolean isSuccess() {
    return verified;
  }
}